<!-- 表格插件 -->
<script src="/static/plugins/bootstrap-table/bootstrap-table.js" type="text/javascript"></script>
<script src="/static/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js" type="text/javascript"></script>
<script src="/static/plugins/bootstrap-table/cookie/bootstrap-table-cookie.js"></script>

<!-- FLOT CHARTS -->
<script src="/static/plugins/flot/jquery.flot.min.js"></script>
<!-- FLOT RESIZE PLUGIN - allows the chart to redraw when the window is resized -->
<script src="/static/plugins/flot/jquery.flot.resize.min.js"></script>
<!-- FLOT PIE PLUGIN - also used to draw donut charts -->
<script src="/static/plugins/flot/jquery.flot.pie.min.js"></script>
<!-- FLOT CATEGORIES PLUGIN - Used to draw bar charts -->
<script src="/static/plugins/flot/jquery.flot.categories.min.js"></script>

<!-- x-editable插件 -->
<script src="/static/plugins/x-editable/js/bootstrap-editable.min.js"></script>
<!-- bootstrap-table启用x-editable插件 -->
<script src="/static/plugins/bootstrap-table/bootstrap-table-editable.js"></script>
<script src="/static/product/scripts/common.js"></script>

<script>
    //初始化加载
    $(function () {
        total();
    });
    /*
     * DONUT CHART
     */
    function total() {
        var url = '{{ urlfor "class/ClassRecordController.ClassDataGrid"}}';
        var data = $("#searchForm").serialize();
        $.sdpost(url, data, function (re) {
            var donutData = re.obj.Valid;
            var donutDataBack = re.obj.Back;
            $(".Student").html(re.obj.Count);
            $(".StudentBack").html(re.obj.BackCount);
            if (donutData.length > 0) {
                $.plot("#donut-chart", donutData, {
                    series: {
                        pie: {
                            show: true,
                            radius: 1,
                            innerRadius: 0.5,
                            label: {
                                show: true,
                                radius: 2 / 3,
                                formatter: labelFormatter,
                                threshold: 0.1
                            }

                        }
                    },
                    legend: {
                        show: false
                    }
                });
            }
            if (donutDataBack.length > 0) {
                $.plot("#donut-chart-back", donutDataBack, {
                    series: {
                        pie: {
                            show: true,
                            radius: 1,
                            innerRadius: 0.5,
                            label: {
                                show: true,
                                radius: 2 / 3,
                                formatter: labelFormatter,
                                threshold: 0.1
                            }

                        }
                    },
                    legend: {
                        show: false
                    }
                });
            }

        });
    }
    /*
     * END DONUT CHART
     */
    function labelFormatter(label, series) {
        return '<div style="font-size:13px; text-align:center; padding:2px; color: #fff; font-weight: 600;">'
                + label
                + "<br>"
                + Math.round(series.percent) + "%</div>";
    }
    //清除搜索
    $("#btnClearSearch").on("click", function (e) {
        $searchForm = $("#searchForm");
        $('select', $searchForm).selectpicker('val', '');
        $('input', $searchForm).val('');
        refreshToFirstPage();
    });
    //刷新并跳转至第一页
    function refreshToFirstPage() {
        total();
    }
</script>